<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>类继承</title>
</head>

<body>

  <script>
    // 手机
    function Phone(brand, price) {
      this.brand = brand;
      this.price = price;
    }

    Phone.prototype.calls = function () {
      console.log('我可以改变世界')
    }

    // 智能手机
    function SmartPhone(brand, phone, color, size) {
      Phone.call(this, brand, phone)
      this.color = color;
      this.size = size;
    }

    // 设置子集构造函数的原型
    SmartPhone.prototype = new Phone;
    SmartPhone.prototype.constructor = SmartPhone;

    // 声明子类的方法
    SmartPhone.prototype.photo = function () {
      console.log('我可以拍照');
    }

    SmartPhone.prototype.playGame = function () {
      console.log('我可以玩游戏');
    }

    const chuizi = new SmartPhone('锤子', 2499, '黑色', '5.5inch');

    console.log(chuizi)

  </script>
</body>

</html>